﻿<UserControl x:Class="Coproject.Views.ToDoListsView"
    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
    xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
    xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
    xmlns:cal="clr-namespace:Caliburn.Micro;assembly=Caliburn.Micro"
    xmlns:bi="clr-namespace:CoProjectDF.Controls"
    xmlns:local="clr-namespace:Coproject.Controls"
    mc:Ignorable="d" d:DesignHeight="300" d:DesignWidth="400"
    >

    <d:DesignProperties.DataContext>
        <Binding Path="ToDoListsViewModel" Source="{StaticResource ViewModelLocator}"/>
    </d:DesignProperties.DataContext>

    <Grid x:Name="LayoutRoot">
        <Grid.ColumnDefinitions>
            <ColumnDefinition Width="6*" />
            <ColumnDefinition Width="5*" />
        </Grid.ColumnDefinitions>
        <Grid.RowDefinitions>
            <RowDefinition Height="auto" />
            <RowDefinition Height="*" />
        </Grid.RowDefinitions>

        <Border Style="{StaticResource FilterPanelStyle}">
            <Grid>
                <Grid.ColumnDefinitions>
                    <ColumnDefinition Width="*" />
                    <ColumnDefinition Width="auto" />
                </Grid.ColumnDefinitions>

                <local:ExtendedTextBox x:Name="Filter" Style="{StaticResource FilterTextBoxStyle}" 
                                           cal:Message.Attach="LoadData" />
                <local:ImageButton x:Name="LoadData" Grid.Column="1" ImageName="Search" ToolTipService.ToolTip="Search" />
            </Grid>
        </Border>

        <ScrollViewer Grid.Row="1" Style="{StaticResource ListsScrollViewerStyle}">
            <ItemsControl x:Name="Lists">
                <ItemsControl.ItemTemplate>
                    <DataTemplate>
                        <StackPanel>
                            <TextBlock Text="{Binding Name}"         FontWeight="Bold"   Style="{StaticResource DefaultTextBlockStyle}" />
                            <TextBlock Text="{Binding Description}"  TextWrapping="Wrap" Style="{StaticResource DefaultTextBlockStyle}" />

                            <ListBox ItemsSource="{Binding ToDoItems}" cal:Message.Attach="OpenItemDetail($this)"
                                         Margin="5,0,0,0" ScrollViewer.HorizontalScrollBarVisibility="Disabled">
                                <ListBox.ItemTemplate>
                                    <DataTemplate>
                                        <StackPanel Orientation="Horizontal">
                                            <TextBlock Text="{Binding DueDate,StringFormat='\{0:d\}'}" FontWeight="Bold" Margin="0,0,5,0" />
                                            <TextBlock Text="{Binding Content}" />
                                        </StackPanel>
                                    </DataTemplate>
                                </ListBox.ItemTemplate>
                            </ListBox>

                        </StackPanel>
                    </DataTemplate>
                </ItemsControl.ItemTemplate>
            </ItemsControl>
        </ScrollViewer>

        <StackPanel Grid.Column="1" Orientation="Horizontal" HorizontalAlignment="Right" Margin="0,-25,0,0">
            <TextBlock Text="Opened details: " Style="{StaticResource StatusTextBlockStyle}" />
            <TextBlock x:Name="Lists_Count" Style="{StaticResource StatusTextBlockStyle}" />
        </StackPanel>

        <ContentControl x:Name="Toolbar" Grid.Column="1" Grid.Row="0" Margin="10,0,0,0" HorizontalContentAlignment="Stretch" 
                cal:View.Model="{Binding ActiveItem}" cal:View.Context="Toolbar" />

        <ContentControl x:Name="ActiveItem" Grid.Column="1" Grid.Row="1" Margin="10,0,0,0" HorizontalContentAlignment="Stretch" />

    </Grid>

</UserControl>
